package com.aerospace.webapi.controller;

import com.aerospace.webapi.domain.user.User;
import org.springframework.web.bind.annotation.*;

@RestController  //@RestController = @Controller + @ResponseBody
public class MVCController {

//    @RequestMapping("/boot/getUser")
    @RequestMapping(value = "/boot/getUser",method = RequestMethod.GET)
    @GetMapping("/boot/getUser")
    public Object getUser(){
        User user = new User();
        user.setId(1);
        user.setName("张无忌");
        return user;
    }

    /**
     * 只支持get请求 @GetMapping = @RequestMapping + RequestMethod.GET
     * @return
     */
    @GetMapping("/boot/getUser1")
    public Object getUser1(){
        User user = new User();
        user.setId(1);
        user.setName("张无忌-get");
        return user;
    }


    /**
     * 只支持post请求 @PostMapping = @RequestMapping + RequestMethod.POST
     * @return
     */
    @PostMapping("/boot/getUser2")
    public Object getUser2(){
        User user = new User();
        user.setId(1);
        user.setName("张无忌-post");
        return user;
    }
}
